const { override, fixBabelImports, addLessLoader, overrideDevServer } = require('customize-cra')
const darkThemeVars = require('antd/dist/dark-theme')
const path = require('path')
function resolve(dir) {
    return path.join(__dirname, '.', dir)
}
const addProxy = () => (configFunction) => {
    configFunction.proxy = {
        '/zhuzi': {
            target: 'http://47.111.161.238/zhuzi',
            changeOrigin: true,
            pathRewrite: { '^/zhuzi': '/' },
        },
    };

    return configFunction;
}
module.exports = {
    webpack: override(
        fixBabelImports("import", {
            libraryName: "antd",
            libraryDirectory: "es",
            style: true
        }),
        addLessLoader({
            javascriptEnabled: true,
            modifyVars: {
                hack: `true;@import "${require.resolve(
                    "antd/lib/style/color/colorPalette.less"
                )}";`,
                // ...darkThemeVars,
                // "@primary-color": "#02b875"
            }
        }),
        (config) => {
            if (process.env.NODE_ENV === 'production') {
                config.output.publicPath = './'
            }
            return config
        }
    ),
    devServer: overrideDevServer(
        addProxy()
    )
};
